package com.fyp.ptma.property;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.springframework.web.client.ResourceAccessException;

public class PropertyFile extends Properties {
	private static final String JSP_PROPERTIES = "/page.strings.properties";
	private static Properties property = null;

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * @param args
	 */
	public static void main(String[] args) {

	}

	private PropertyFile() {

	}

	public static String valueOf(String propertyName) {
		if (null == property) {
			InputStream is = PropertyFile.class.getClassLoader()
					.getResourceAsStream(JSP_PROPERTIES);
			if (is == null) {
				throw new ResourceAccessException(
						"Can not load property file::: " + JSP_PROPERTIES);

			}
			property = new PropertyFile();
			try {
				property.load(is);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				throw new ResourceAccessException(
						"Can not load property file::: " + JSP_PROPERTIES);
			}

		}
		return property.getProperty(propertyName);

	}

}
